# Replication Archive for: 
# Coppock, Alexander and Donald P. Green. 2020. 
# "Do Belief Systems Exhibit Dynamic Constraint?" 
# The Journal of Politics, Forthcoming.

rm(list = ls())

library(tidyverse)
library(estimatr)
library(stargazer)

study_2 <- read_rds("data/clean/study_2_lucid_clean.rds")
study_2_replication <-
  read_rds("data/clean/studies_1_2_replications_lucid_cleaned.rds")


# Study 2 version ---------------------------------------------------------

fit_1 <- lm(welfare_good ~ Z_welfare, data = study_2)
fit_2 <- lm(gov_reduce_ineq ~ Z_welfare, data = study_2)
fit_3 <- lm(medicaid_good ~ Z_welfare, data = study_2)


stargazer(fit_1, fit_2, fit_3,
          p = starprep(fit_1, fit_2, fit_3, stat = "p.value"),
          se = starprep(fit_1, fit_2, fit_3),
          dep.var.labels = c("Too Little on Welfare", "Gov't Should Reduce Ineq.", "Medicaid a Good Thing"),
          covariate.labels = c("Welfare Wording", "Constant (Aid to the Poor)"),
          style = "apsr",
          column.sep.width = "0pt",
          omit.stat = c("f", "ser", "rsq", "adj.rsq"),
          star.cutoffs = c(0.05),
          label = "tab:welfare",
          notes = c("Robust standard errors are in parentheses."),
          font.size = "footnotesize",
          title = "Welfare Experimental Results",
          out = "../Drafts/tables/welfare.tex")


# Replication version -----------------------------------------------------


fit_1 <- lm(welfare_good ~ Z_welfare, data = study_2_replication)
fit_2 <- lm(gov_reduce_ineq ~ Z_welfare, data = study_2_replication)
fit_3 <- lm(medicaid_good ~ Z_welfare, data = study_2_replication)


stargazer(fit_1, fit_2, fit_3,
          p = starprep(fit_1, fit_2, fit_3, stat = "p.value"),
          se = starprep(fit_1, fit_2, fit_3),
          dep.var.labels = c("Too Little on Welfare", "Gov't Should Reduce Ineq.", "Medicaid a Good Thing"),
          covariate.labels = c("Welfare Wording", "Constant (Aid to the Poor)"),
          style = "apsr",
          column.sep.width = "0pt",
          omit.stat = c("f", "ser", "rsq", "adj.rsq"),
          star.cutoffs = c(0.05),
          label = "tab:welfare",
          notes = c("Robust standard errors are in parentheses."),
          font.size = "footnotesize",
          title = "Welfare Experimental Results",
          out = "../Drafts/tables/welfare_replication.tex")